package xyz.jangle.list.priority;

import java.util.concurrent.PriorityBlockingQueue;

public class M {

	public static void main(String[] args) {
		
		PriorityBlockingQueue<Model> queue = new PriorityBlockingQueue<Model>();
		
		queue.offer(new Model("a",1));
		queue.offer(new Model("b",3));
		queue.offer(new Model("c",2));
		queue.offer(new Model("d",2));
		
		System.out.println(queue.poll().getName());
		System.out.println(queue.poll().getName());
		System.out.println(queue.poll().getName());
		System.out.println(queue.poll().getName());

	}

}

class Model implements Comparable<Model>{
	
	private String name;
	private int age;
	
	public Model(String name, int age) {
		super();
		this.name = name;
		this.age = age;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	@Override
	public int compareTo(Model o) {
		return this.age - o.age;
	}
	
	
}
